#ifndef __VFS_UTILS_H__
#define __VFS_UTILS_H__

//type convert functions
#ifndef MIN
#define MIN(x, y) ((x) < (y) ? (x) : (y))
#endif

// lock functions
#ifndef WIN32
	#define LOCK(l)	OS_LockMutex(l, TMO_FEVR)
	#define UNLOCK(l) OS_UnlockMutex(l)
#else
	#define LOCK(l)	EnterCriticalSection(&l)
	#define UNLOCK(l) LeaveCriticalSection(&l)
#endif //WIN32


int new_lock(lock *l);
int free_lock(lock *l);

long atomic_add( long *ptr, long val );
int snooze(int f);

#ifdef WIN32
	void panic( const char *format, ... );
	void null_printf( const char *format, ... );
#else
	//#define panic(fmt, args...) do{libc_printf(fmt, ##args); while(1);}while(0)
    #define panic(fmt, args...) do{while(1);}while(0)
#endif


#define BUF_ALIGN(x, y) (((uint32)(x)  + ((y) - 1)) & (~((y) - 1)))
//some sub string functions
char *strdup(const char *s);
size_t strlcpy(char *dst, const char *src, size_t siz);
size_t strlcat(char *dst, const char *src, size_t siz);

#ifndef WIN32
	#define time(...) osal_get_tick()
#endif


#endif// __VFS_UTILS_H__

